Skip to content

Add Last.fm Recommendations music provider#3020

Open
OzGav wants to merge 7 commits intodevfrom
claude/debug-album-resolution-hooa2
Open

Add Last.fm Recommendations music provider#3020
OzGav wants to merge 7 commits intodevfrom
claude/debug-album-resolution-hooa2

Conversation

@OzGav
Copy link
Copy Markdown
Contributor

@OzGav OzGav commented Jan 26, 2026

A new music provider that generates recommendation folders using the Last.fm API. Recommendations are resolved to playable items via streaming providers (Spotify, etc).

Recommendation Rows

The provider generates up to 9 recommendation folders, arranged into four groups configurable via toggle:

Personalized (based on user's MA library play counts)

  • Discover Similar Artists: Top 5 most-played artists → 3 similar each → dedupe → first 10
  • Discover Similar Tracks: Top 5 most-played tracks → 3 similar each → dedupe → first 10

Global Charts (Last.fm worldwide data)

  • Global Top Artists: Request 15 → resolve → dedupe → first 10
  • Global Top Tracks: Request 15 → resolve → dedupe → first 10

Genre-based (requires Last.fm username)

  • Discover {Genre} Artists: User's top tag → 30 artists → filter library → top 3 + random 12 → resolve → first 10
  • Discover {Genre} Albums: User's top tag → 30 albums → filter library → top 3 + random 12 → resolve → first 10
  • Discover {Genre} Tracks: User's top tag → 30 tracks → filter library → top 3 + random 12 → resolve → first 10

Geographic (configurable country)

  • Top Artists in {Country}: Request 15 → resolve → dedupe → first 10
  • Top Tracks in {Country}: Request 15 → resolve → dedupe → first 10

Resolution Pipeline

  1. Last.fm API returns artist/track/album names with optional MusicBrainz IDs (MBIDs)
  2. For tracks: MBID → MusicBrainz API → ISRC lookup
  3. Search streaming providers by ISRC (preferred) or name+artist fallback
  4. Results cached at two levels: in-memory (session) and persistent (90 days)

Key Features

  • All recommendation groups are disabled by default (user enables what they want)
  • Configurable refresh interval (default 6 hours)
  • 20-second startup delay to allow streaming providers to load first
  • Genre rows use "top 3 + random sample" strategy with daily seed for variety
  • Library items filtered from genre recommendations to surface new music
  • Refresh Now button in advanced settings for manual refresh

@OzGav OzGav marked this pull request as draft January 26, 2026 16:34
@OzGav OzGav marked this pull request as ready for review January 26, 2026 16:35
@OzGav OzGav force-pushed the claude/debug-album-resolution-hooa2 branch 2 times, most recently from 39c8072 to 301d2fa Compare January 26, 2026 23:07
@MarvinSchenkel MarvinSchenkel added this to the 2.9.0 milestone Mar 12, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 17, 2026

🔒 Dependency Security Report

✅ No dependency changes detected in this PR.

@marcelveldt
Copy link
Copy Markdown
Member

I keep forgetting to come back on this one.
What we want is that metadata providers can also provide recommendations.

Long term goal is that we can have provider independent recommendations providers.
Based on services like listenbrainz, lastfm and ofcourse... AI

Now question is if this belongs to metadata providers or this should be plugins.
It definitely does not belong to the normal music providers as these providers do not provide music/audio on their own, they provide recommendations based on what you already have.

Also metadata is strictly about metadata so I'm inclined to say this should be plugin.
What do you think @OzGav ?

@OzGav
Copy link
Copy Markdown
Contributor Author

OzGav commented Apr 3, 2026

As discussed on Discord. Changed to a metadata provider.

OzGav and others added 3 commits April 15, 2026 12:09
Adds +isrcs to the MusicBrainz recording include clause so that
get_recording_details returns ISRC codes. Required by the Last.fm
Recommendations provider to resolve tracks to streaming providers via
ISRC matching.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Mirrors the default implementation on MusicProvider, allowing metadata
providers to declare ProviderFeature.RECOMMENDATIONS and contribute
recommendation folders to the Home screen.

The dispatch in controllers/music.py already filters providers by
feature rather than by class, so no controller changes are needed.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Adds a new MetadataProvider that surfaces Last.fm-powered recommendation
rows on the Home screen, grouped into four configurable toggles:

- Personalized (similar artists/tracks based on your listening history)
- Global Charts (Last.fm worldwide top artists/tracks)
- Genre (top artists/albums/tracks for your most-played Last.fm genre;
  requires username)
- Geographic (top artists/tracks for a selected country)

Items returned by Last.fm are resolved to your configured streaming
providers using MBIDs and ISRCs where available, falling back to name
matching. Resolved items are cached for 90 days and MBID to ISRC
lookups for 90 days. Built recommendation folders are persisted for
24 hours so they survive restarts without re-hitting APIs.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@OzGav OzGav force-pushed the claude/debug-album-resolution-hooa2 branch from b406df8 to 7f7f309 Compare April 15, 2026 02:14
OzGav added 4 commits April 15, 2026 12:30
The music controller's recommendations() aggregator was iterating
self.providers, which filters to ProviderType.MUSIC only. With the
Last.fm provider moving to MetadataProvider, its folders were never
dispatched even though the feature flag was set.

Iterate self.mass.providers (all types) and filter by
ProviderFeature.RECOMMENDATIONS instead, preserving the existing
user_provider_filter logic.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants